import React from 'react';
import { testGet, testPost, testPut } from 'shared/api';
import Nav from 'shared/components/nav';
import subwayColorEnum from '../consts/subwayColorEnum';

import './index.less';

export default class WayList extends React.PureComponent {
  componentDidMount() {
    testGet({ a: 'test' }).then((res) => {
      console.log(res);
      return res;
    });

    testPost({ a: 'testPost' }).then((res) => {
      console.log(res);
    });


    testPut({ id: '3232' }, { name: 'yang', age: 23 }).then((res) => {
      console.log(res);
    });
  }

  redirect(value) {
    this.props.history.push(`/waydetail/${value}`);
  }

  render() {
    return (
      [
        <Nav title="列车位置" key="nav" isBlack={false} className="subway-list-nav" />,
        <div className="subway-list-container" key="subway-list">
          <div className="subway-list">
            {
            [1, 2, 3, 4, 7, 10].map((value, index) => (
              <div className="subway-list-line" onClick={() => this.redirect(value)}>
                <span
                  className="subway-list-line-index"
                  style={{ backgroundColor: subwayColorEnum[value] }}
                >
                  {index + 1}
                </span>
                <div>
                  <span className="subway-name">{`${index + 1}号线`}</span>
                  <span className="subway-info">韦家碾 - 科学城、五根松</span>
                </div>
              </div>
            ))
          }
          </div>
        </div>,
      ]
    );
  }
}
